import { ajaxGet } from '@/util'
import { resolve } from 'tinymce'
export default ({
  state: {
    basicForm: {
      distributorMobile: '',
    },
    brandDtos: '',
    getSubInfoList: []
  },
  mutations: {
    setEmptyDealer(state) {
      state.getSubInfoList = []
      state.basicForm = {
        distributorMobile: ''
      }
    }
  },
  actions: {
    getBasicData({state, commit, getters}, params) {
      return new Promise((resolve, reject) => {
        ajaxGet(`/distributor/contract/find_distributor/${params.distributorId}`).then(res => {
          delete res.distributorCategoryDTOList
          for (let key in res) {
            params.self.$set(state.basicForm, key, res[key])
          }
          resolve(res)
        })
      })
    },
    getSubInfo({state, commit, getters}, params) {
      return new Promise((resolve, reject) => {
        ajaxGet(`/distributor/contract/find_distributor_contract/${params.distributorId}`).then(res => {
          state.getSubInfoList = res
          resolve(res)
        })
      })
    }
  },
  getters: {
    basicForm(state) {
      return state.basicForm
    }
  }
})